<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>WebWorker示例</title>
    <script type="text/javascript">
        window.onload = function () {
            let btn1 = document.getElementById('btn1');
            let number = document.getElementById('text');
            btn1.onclick = function(){
                let worker = new Worker('../../js/worker.js');
                worker.postMessage(number.value);
                worker.onmessage = function (event){
                    alert(event.data);
                }
            }
        }
    </script>
</head>
<body>
<input type="text" id="text">
<button id="btn1" value="">计算</button>
</body>
</html>